﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Job.Web.Framework;
using System.Collections;

namespace Job.Logic.Common
{
    public class SubjectLogic
    {
        #region 取得二级栏目数据

        public DataTable GetSubjectData()
        {
            #region Add column

            DataTable dt = new DataTable();
            DataColumn titleColumn = new DataColumn();
            titleColumn.ColumnName = "title";
            titleColumn.DataType = System.Type.GetType("System.String");
            titleColumn.AllowDBNull = true;
            dt.Columns.Add(titleColumn);

            DataColumn imgColumn = new DataColumn();
            imgColumn.ColumnName = "imagePath";
            imgColumn.DataType = System.Type.GetType("System.String");
            imgColumn.AllowDBNull = true;
            dt.Columns.Add(imgColumn);


            DataColumn subidColumn = new DataColumn();
            subidColumn.ColumnName = "subject_id";
            subidColumn.DataType = System.Type.GetType("System.Int32");
            subidColumn.AllowDBNull = true;
            dt.Columns.Add(subidColumn);


            DataColumn contentidColumn = new DataColumn();
            contentidColumn.ColumnName = "content_id";
            contentidColumn.DataType = System.Type.GetType("System.Int32");
            contentidColumn.AllowDBNull = true;
            dt.Columns.Add(contentidColumn);
            
            #endregion


            dt.Rows.Add(new object[] { "猎头说明", "images/hunter_desc.png", 110, 110 });
            dt.Rows.Add(new object[] { "猎头资讯", "images/fee.png", 113, 113 });
            dt.Rows.Add(new object[] { "猎头职位", "images/position.png", 111, 111 });
            dt.Rows.Add(new object[] { "管理专区", "images/process.png", 115, 115 });
            dt.Rows.Add(new object[] { "联系方式", "images/statement.png", 116, 116 });
            
            return dt;
        }

        #endregion

        public DataTable GetMenuTitle()
        {
            #region Add column

            DataTable dt = new DataTable();
            DataColumn titleColumn = new DataColumn();
            titleColumn.ColumnName = "title";
            titleColumn.DataType = System.Type.GetType("System.String");
            titleColumn.AllowDBNull = true;
            dt.Columns.Add(titleColumn);

            DataColumn imgColumn = new DataColumn();
            imgColumn.ColumnName = "CSS";
            imgColumn.DataType = System.Type.GetType("System.String");
            imgColumn.AllowDBNull = true;
            dt.Columns.Add(imgColumn);


            DataColumn subidColumn = new DataColumn();
            subidColumn.ColumnName = "category_id";
            subidColumn.DataType = System.Type.GetType("System.Int32");
            subidColumn.AllowDBNull = true;
            dt.Columns.Add(subidColumn);

            #endregion

            dt.Rows.Add(new object[] { "猎头专区", "HunterBG", 11 });
            dt.Rows.Add(new object[] { "关于无忧", "HunterBG", 10 });
            dt.Rows.Add(new object[] { "人事外包", "HunterBG", 12 });
            dt.Rows.Add(new object[] { "个人求职", "HunterBG", 14 });
            dt.Rows.Add(new object[] { "企业招聘", "HunterBG", 15 });
            return dt;
        }


        public DataSet GetBaseContentList(int pageSize, int pageIndex, int countType, string sortField, SortDirection sortDirection, ArrayList paramList)
        {
            string sql = @"select content_id,title,description,status_id,order_no,
                            subject_id,count,last_update_time,last_update_user
                            from job_base_content where status_id =1 ";

            foreach (SqlParameter param in paramList)
            {
                switch (param.ParameterName)
                {
                    case "subject_id":
                        sql += " and subject_id = " + param.Value + "";
                        break;
                }
            }

            CommonLogic logic = new CommonLogic();
            DataSet ds = logic.GetPageDataBySqlTwoFieldOrder(sql, pageSize, pageIndex, countType, sortField, sortDirection, paramList);
            return ds;
        }

    }
}